// 转换商业险配置数据
import { syCode, keyList, getPreConfItem, preConfList } from '@/components/ivew_conf/car_sy_plan'

export default (ctx, next) =>{

    let syRisk = ctx.params.DEVsyRiskTable; 
    let cache:formInf.syData[] = getPreConfItem('自定义', preConfList());
    let EnumKeys = keyList(true);
    let keys = keyList();
    let boLiKey:formInf.carPlanKey = 'boLi';

    // 填入数据(未选择商业险, 将不返回该关键字)
    if(syRisk){
        syRisk.forEach(item =>{

            let syItem:formInf.syData =  {
                checked: true,
                key: syCode[item.code],
                value: item.insuredAmount,
                jp: item.noInsuranceExclusions
            };
    
            // 玻璃取值特例
            if(syItem.key === boLiKey){
                syItem.value = item.notes;
            }
    
            let index = EnumKeys[syItem.key];
            Object.assign(cache[index], syItem);
    
        })
    }
    ctx.params.DEVsyRiskTable = cache;
    next()
}